export const schema = {
    type: "page",
    title: "回复消息",
    body: [
        {
            type: "nav",
            stacked: false,
            links: [
                {
                    label: "用户新帖",
                    to: "/feeling_tone/list?org_id=${org_id}"
                },
                {
                    label: "回复消息",
                    to: "/feeling_tone/comments?org_id=${org_id}"
                }
            ]
        },

        {
            type: "wrapper",
            className: "b-l b-b b-r bg-white no-padder",

            body: [
                {
                    visibleOn: '!data.org_id && !acl.can("skip:select-org")',
                    type: 'tpl',
                    className: 'wrapper',
                    tpl: `<div class="alert alert-warning">请先选择一个机构</div>`
                },

                {
                    visibleOn: 'data.org_id || acl.can("skip:select-org")',
                    type: "crud",
                    className: 'bg-white',
                    api: "/api/feeling_tone/comments?org_id=${org_id}&page=${page}&fid=${fid}&author=${author}&start_time=${start_time}&end_time=${end_time}",
                    panelClassName: "no-border no-shadow bg-white",
                    toolbarInline: true,
                    columnsTogglable: false,
                    filter: {
                        panelClassName: 'm-l m-r m-b-xs',
                        title: '',
                        submitText: '',
                        controls: [
                            {
                                label: '发布人',
                                type: 'text',
                                placeholder: '用户名/手机号',
                                name: 'author'
                            },
    
                            {
                                label: '发布时间',
                                type: 'datetime',
                                name: 'start_time',
                                inputFormat: 'YYYY-MM-DD HH:mm:ss'
                            },
    
                            {
                                label: '到',
                                type: 'datetime',
                                name: 'end_time',
                                inputFormat: 'YYYY-MM-DD HH:mm:ss'
                            },
                            {
                                type: 'submit',
                                label: '搜索',
                                primary: true
                            }
                        ]
                    },
                    columns: [
                        {
                            label: "序号",
                            name: 'id'
                        },
                        {
                            label: "评论时间",
                            innerClassName: 'w-sm block',
                            name: "created_at"
                        },
                        {
                            label: "原帖发布人",
                            type: 'tpl',
                            tpl: '${post.author.username}'
                        },
                        {
                            label: "评论人",
                            type: 'tpl',
                            tpl: '${author.username}'
                        },
                        {
                            label: "联系电话",
                            type: 'tpl',
                            tpl: '${author.phone}'
                        },
                        {
                            label: '内容',
                            innerClassName: 'w',
                            type: 'tpl',
                            tpl: '${comment|truncate:15}'
                        },
                        {
                            type: 'operation',
                            label: '操作',
                            buttons: [
                                {
                                    type: 'button',
                                    label: '查看',
                                    level: 'info',
                                    actionType: 'dialog',
                                    dialog: {
                                        title: '',
                                        body: `
                                        <h4>内容详情</h4>
                                        <p><%= data.comment %></p>
                                        <hr />
                                        <h4>帖子地址</h4>
                                        <div class="text-center">
                                            
                                            <img src="/qrcode?size=250&data=<%= encodeURIComponent(data.post.preview_url) %>" />
                                        </div>
                                        `
                                    }
                                },
                                {
                                    type: 'button',
                                    label: '回复',
                                    actionType: 'dialog',
                                    visibleOn: 'acl.can("feeling_tone:reply")',
                                    dialog: {
                                        title: '回复',
                                        body: {
                                            type: 'form',
                                            api: 'post:/api/feeling_tone/reply',
                                            controls: [
                                                {
                                                    type: 'hidden',
                                                    name: 'id'
                                                },
                                                {
                                                    type: 'tpl',
                                                    tpl: '回复：${comment}',
                                                    className: 'm-b'
                                                },
                                                {
                                                    type: 'textarea',
                                                    name: 'content',
                                                    label: false
                                                }
                                            ]
                                        }
                                    }
                                },
                                {
                                    type: 'button',
                                    label: '删除',
                                    level: 'danger',
                                    confirmText: '确定要删除吗？',
                                    actionType: 'ajax',
                                    visibleOn: 'acl.can("feeling_tone:delete")',
                                    api: 'delete:/api/feeling_tone/comment/${id}'
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
};
